package edu.sctu.wangfuxin.day20150520;

/**
 * Created by user06 on 2015/5/17.
 */
public class TextOne extends TextMore {

    /**
     * getTercherInfo() 对老师学号排序后输出老师信息
     * @param
     */

    public TeaCher[] getTercherInfo(TeaCher[] th){
        System.out.println("老师按编号排序后：");
        TeaCher[] th1= new TeaCher[th.length];
        th1 = sortNumber(th);
        for (int j = 0; j < th.length; j++) {
            System.out.println("老师姓名：" + th1[j].name + " 老师编号：" + th1[j].number + " 老师年龄："
                    + th1[j].age + " 老师性别：" + th1[j].sex + " 老师所教课程：" + th1[j].kecheng
                    + " 老师职称:" + th1[j].zhicheng);
        }
        return th1;

    }

    public StudentMassage[] getStudentCode(int code, StudentMassage[] s1) {
        sotrStudent(s1);
        StudentMassage[] studentcode = new StudentMassage[s1.length];
        for (int i = 0; i < s1.length; i++) {
            if (code < s1[i].getCode()) {
                studentcode[i] = s1[i];
            }
        }//处理学生成绩排序后的成绩大于coed的学
        return studentcode;
    }

    public StudentMassage[] getCode(TeaCher[] tea){
        TeaCher tea1 = pritCode(tea);
        StudentMassage[] studentnumber  = interFace.getStudents(tea1.student);
        return studentnumber;
    }

    IterFace interFace = new IterFace() {
        @Override
        public StudentMassage[] getStudents(StudentMassage[] student) {
            StudentMassage[] studentnumber =  getStudentCode(60,student);
            return studentnumber;
        }
    };





    public void getCourse(TeaCher[] th){
        int couter1 = 0;
        int couter2 = 0;
        int couter3 = 0;
        int couter4 = 0;



        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k <3 ; k++) {
                    if (th[i].student[j].courses[k].getCourse()=="计算机") {
                        couter1 = couter1 + 1;
                    }else if (th[i].student[j].courses[k].getCourse()=="数学"){
                        couter2 = couter2+1;
                    }else if(th[i].student[j].courses[k].getCourse()=="语文"){
                        couter3 = couter3+1;
                    }else if(th[i].student[j].courses[k].getCourse()=="物理"){
                        couter4 =couter4+1;
                    }

                }
            }
        }


        int temp = 0;
        int temp1 = 0;
        int temp2 = 0;

        temp = couter1 > couter2? couter1:couter2;
        temp1 = couter3 > couter4? couter3:couter4;
        temp2 = temp > temp1? temp:temp1;


        if (temp2 == couter1) {
            System.out.println("学计算机的然最多！人数为:"+temp2+"   名单如下：");
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        if (th[i].student[j].courses[k].getCourse() =="计算机") {
                            System.out.println(th[i].name + "老师所教学生：" + th[i].student[j].name + " ");
                        }
                    }
                }
            }
        }else if (temp2 == couter2) {
            System.out.println("学数学的然最多！人数为："+temp2+"   名单如下：");
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        if (th[i].student[j].courses[k].getCourse() =="数学") {
                            System.out.print(th[i].name+"老师所教学生："+th[i].student[j].name+"   ");
                        }
                    }
                }
            }
        }else if (temp2 == couter3) {
            System.out.println("学语文的然最多！人数为:"+temp2+"   名单如下：");
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        if (th[i].student[j].courses[k].getCourse() =="语文") {
                            System.out.print(th[i].name+"老师所教学生："+th[i].student[j].name+"   ");
                        }
                    }
                }
            }
        }else {
            System.out.println("学物理的然最多！人数为:"+temp2+"   名单如下：");
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        if (th[i].student[j].courses[k].getCourse() =="物理") {
                            System.out.print(th[i].name+"老师所教学生："+th[i].student[j].name+"   ");
                        }
                    }
                }
            }
        }
    }
}


//        创建一个类为TextOne,TextOne继承自TextMore，TextMore有三个方法，sotrNumber()一个是对老师学号
//        进行排序，sortStudent()一个是对老师所教学生成绩进行排序。pritCoded()一个是对老师职称为教授的进行返回
//
//        TexMain 里面有三个方法 getTercherInfo() 对老师学号排序后输出老师信息，getStudent(int code)处理学生
//        成绩排序后的成绩大于coed的学生。getCode()判断职称为教授的学生有哪些，并调用接口判断学生成绩大于code的
//        学生，判断调用getStudent(int code)方法。
//
//        在Main类里面，调用输出老师排序后的信息，调用处理学生成绩排序后大于code的信息。调用getCode方法输出
//        教授下成绩大于coed的学生。

//在Textone里新增 一个方法getCourse,此方法用于判断学生所选的共同课程
